package com.sec.android.app.myfiles.module.suggestion.cmd;

import android.content.Context;

import com.sec.android.app.myfiles.facade.AbsSimpleThreadCmd;
import com.sec.android.app.myfiles.log.Log;
import com.sec.android.app.myfiles.module.abstraction.FileRecord;
import com.sec.android.app.myfiles.util.FileUtils;

import org.puremvc.java.multicore.interfaces.INotification;

import java.util.List;

public class DeleteSuggestionCmd extends AbsSimpleThreadCmd {

    @Override
    protected void executeThread(INotification notification) {
        Object[] params = (Object[]) notification.getBody();
        try {
            final Context context = (Context) params[0];
            List<FileRecord> recordList = (List<FileRecord>) params[1];
            for (FileRecord record : recordList) {
                if (FileUtils.isAddedToSuggestion(context, record.getFullPath()) > 0) {
                    if (FileUtils.removeSuggestionContent(context, record)) {
                    }
                }
            }
        } catch (ArrayIndexOutOfBoundsException e) {
            Log.e(this, "ArrayIndexOutOfBoundsException:" + e.toString());
        }
    }

}
